package com.nus.fellowmark.modules.module.service.impl;

import com.nus.fellowmark.dao.SupervisionDao;
import com.nus.fellowmark.entity.SupervisionEntity;
import com.nus.fellowmark.modules.module.service.SupervisionService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nus.fellowmark.common.utils.PageUtils;
import com.nus.fellowmark.common.utils.Query;


@Service("supervisionService")
public class SupervisionServiceImpl extends ServiceImpl<SupervisionDao, SupervisionEntity> implements SupervisionService {

    @Autowired
    SupervisionDao supervisionDao;
    
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<SupervisionEntity> page = this.page(
                new Query<SupervisionEntity>().getPage(params),
                new QueryWrapper<SupervisionEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<SupervisionEntity> getByStaffId(Integer staffId) {
        return supervisionDao.selectByStaffId(staffId);
    }

    @Override
    public List<SupervisionEntity> getByModuleId(Integer moduleId) {
        return supervisionDao.selectByModuleId(moduleId);
    }

    @Override
    public SupervisionEntity getByStaffIdAndModuleId(Integer staffId, Integer moduleId) {
        return supervisionDao.selectByStaffIdAndModuleId(staffId, moduleId);
    }

}
